
export default {
  namespaced: true,
  state: {
    isLogin: false,
    id: '',
    avatar: '',
    nickname: '',
    isAuth: false,
    auth: {}
  },
  mutations: {
    login (state, userInfo) {
      state.isLogin = true
      state.id = userInfo._id
      state.avatar = userInfo.avatar
      state.nickname = userInfo.nickname
    },
    logout (state) {
      state.isLogin = false
      state.id = ''
      state.avatar = ''
      state.nickname = ''
      localStorage.setItem('POINT-LINK-TOKEN', '')
    },
    setAuth(state, auth) {
      state.authentication = auth
    }
  },
  actions: {
    login ({ commit }, userInfo) {
      if (userInfo) {
        commit('login', userInfo)
      }
    },
    logout({commit}) {
      commit('logout')
    },
    setAuth({commit}, auth) {
      commit('setAuth', auth)
    }
  },
}
